home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / e / kyz_obj.lha / datestring.e < prev    next >
Text File  |  1998-09-04  |  2KB  |  71 lines

  1. -> A set of strings holding the date in text format
  2.  
  3. OPT MODULE,OSVERSION=36
  4.  
  5. MODULE 'dos/datetime'
  6.  
  7. /****** datestring.m/--overview-- *******************************************
  8. *
  9. *   PURPOSE
  10. *    To represent a textual form of the current date and time.
  11. *
  12. *   OVERVIEW
  13. *    A  very  simple  object  that  datestamps  itself on creation, and
  14. *    transforms  that  datestamp into a set of three strings, which are
  15. *    accessable as the object attributes 'day', 'date' and 'time'.
  16. *
  17. ****************************************************************************
  18. *
  19. *
  20. */
  21.  
  22. CONST DATELEN = LEN_DATSTRING+1
  23.  
  24. EXPORT OBJECT datestring
  25.    day[DATELEN]:ARRAY OF CHAR
  26.   date[DATELEN]:ARRAY OF CHAR
  27.   time[DATELEN]:ARRAY OF CHAR
  28. ENDOBJECT
  29.  
  30. /****** datestring.m/new *******************************************
  31. *
  32. *   NAME
  33. *    datefield.new() -- Constructor.
  34. *
  35. *   SYNOPSIS
  36. *    new()
  37. *       new(format)
  38. *
  39. *   FUNCTION
  40. *    Initialises an instance of the datestring class.
  41. *
  42. *   INPUTS
  43. *    format - the format the 'date' attribute will take:
  44. *             format = 0, dd-mmm-yy (12-Feb-92)
  45. *             format = 1, yy-mm-dd  (92-02-12)
  46. *             format = 2, mm-dd-yy  (02-12-92)
  47. *             format = 3, dd-mm-yy  (12-02-92)
  48. *
  49. *             The default format is 0.
  50. *
  51. *   RESULT
  52. *    The initialised instance now contains three readable attributes:
  53. *        day  - string representing the name of the day, eg 'Monday'
  54. *        date - string representing the current date, eg '27-Feb-94'
  55. *        time - string representing the current time, eg '12:34:56'
  56. *
  57. ****************************************************************************
  58. *
  59. *
  60. */
  61.  
  62. EXPORT PROC new(format=0) OF datestring
  63.   DEF dt:datetime
  64.   dt.strday  := self.day
  65.   dt.strdate := self.date
  66.   dt.strtime := self.time
  67.   dt.format  := format
  68.   DateStamp(dt)
  69.   DateToStr(dt)
  70. ENDPROC
  71.